#include "uthread.h"
#include "types.h"
#include "user.h"

int iters = 0;

void haha(){
    int i=0;
    while (i< iters) {
        printf(1, "thread %d iteration %d\n", uthread_self().tid , i);
        uthread_yield();
        i++;
    }
}

int main(int argc, char** argv){
    int n,i=0;

    if (argc == 3) {
        n = atoi(argv[1]);
        iters = atoi(argv[2]);        
        //printf(1, "[number of threads]=%d [number of iterations]=%d\n\n",n,iters);
    }else{
        printf(1, "invalid input!\nplease enter: uthread_sanity [number of threads] [number of iterations]\n\n");
	exit();
    }
    while (i < n) {
        uthread_create(&haha,0);
        i++;
    }
    uthread_start_all();
    
    printf(1, "shouldn't be here...!!!!!\n");
    exit();
    return 1;
}
